<?php

/**
 * NeoPersona form.
 *
 * @package    neoTrainner
 * @subpackage form
 * @author     Your name here
 */
class NeoPersonaForm extends BaseNeoPersonaForm {

    public function configure() {
        unset(
                $this['created_at'], $this['updated_at']
        );
        
        $this->widgetSchema['idEvento'] = new sfWidgetFormInputHidden();

        $this->widgetSchema['nombre'] = new sfWidgetFormInputText(array(), array('size' => 30));
        $this->widgetSchema['apellido'] = new sfWidgetFormInputText(array(), array('size' => 30));
        $this->widgetSchema['domicilio'] = new sfWidgetFormInputText(array(), array('size' => 65));
        $this->widgetSchema['codigo_postal'] = new sfWidgetFormInputText(array(), array('size' => 8));
        $this->widgetSchema['localidad'] = new sfWidgetFormInputText(array(), array('size' => 27));
        $this->widgetSchema['telefono'] = new sfWidgetFormInputText(array('label' => 'Teléfono'), array('size' => 30));
        $this->widgetSchema['email'] = new sfWidgetFormInputText(array(), array('size' => 30));
        $this->widgetSchema['otro_running_team'] = new sfWidgetFormInputText(array('label' => 'Otro'), array('size' => 30));
        $this->widgetSchema['otra_cobertura_medica'] = new sfWidgetFormInputText(array('label' => 'Otro'), array('size' => 30));
        $this->widgetSchema['nombre_contacto_emergencia'] = new sfWidgetFormInputText(array('label' => 'Nombre'), array('size' => 30));
        $this->widgetSchema['telefono_contacto_emergencia'] = new sfWidgetFormInputText(array('label' => 'Teléfono'), array('size' => 30));
        
        $this->widgetSchema['neo_cobertura_medica_id'] = new sfWidgetFormPropelChoice(array('model' => 'NeoCoberturaMedica', 'add_empty' => false, 'label' => 'Cobertura Médica'));
        $this->widgetSchema['neo_talle_remera_id'] = new sfWidgetFormPropelChoice(array('model' => 'NeoTalleRemera', 'add_empty' => false, 'label' => 'Talle Remera'));
        $this->widgetSchema['neo_running_team_id'] = new sfWidgetFormPropelChoice(array('model' => 'NeoRunningTeam', 'add_empty' => false, 'label' => 'Equipo/Grupo'));
        

        $yearFrom = date('o') - sfConfig::get('app_edades_hasta');
        $yearTo = date('o') - sfConfig::get('app_edades_desde');
        $middleYear = date('o') - sfConfig::get('app_edades_media');
        $this->widgetSchema['fecha_nacimiento'] = new sfWidgetFormDateJQueryUI(
                        array("change_month" => true, "change_year" => true, "culture" => "es",
                            "yearRange" => $yearFrom . ':' . $yearTo,
                            "defaultDate" => 'new Date(' . $middleYear . ',0,1)'));

        $this->widgetSchema['sexo'] = new sfWidgetFormChoice(array(
                    'choices' => NeoPersonaPeer::$sexos,
                    'multiple' => false,
                    'default' => NeoPersonaPeer::SEXO_MASCULINO,
                    'expanded' => true
                ));

        $this->validatorSchema['email'] = new sfValidatorEmail(
                        array('required' => true),
                        array('required' => "Mail incorrecto")
        );


        $this->validatorSchema['nombre'] = new sfValidatorAnd(
                        array($this->validatorSchema['nombre'],
                            new sfValidatorString(
                                    array(),
                                    array(
                                        'required' => 'Obligatorio.'
                                    )
                            )
                        )
        );
        
        $this->validatorSchema['idEvento'] = new sfValidatorPropelChoice(array('model' => 'NeoEvento', 'column' => 'id', 'required' => true));


    }

}
